﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chinesys.Domain.InputValidations
{
    public abstract class InputValidationError
    {
        public string PropertyName { get; set; }
        public abstract string ErrorMessage { get; }
        public string AdditionalInfo { get; set; }
    }

    public class Required : InputValidationError
    {
        public Required(string propertyName)
        {
            base.PropertyName = propertyName;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' es Requerido", PropertyName); }
        }
    }

    public class Range : InputValidationError
    {
        private decimal max;
        private decimal min;

        public Range(string propertyName, decimal min, decimal max)
        {
            base.PropertyName = propertyName;
            this.min = min;
            this.max = max;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' debe estar comprendido en el rango ({1} - {2}).", PropertyName, min, max); }
        }
    }

    public class GreaterThanZero : InputValidationError
    {
        public GreaterThanZero(string propertyName)
        {
            base.PropertyName = propertyName;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' debe ser mayor a cero.", PropertyName); }
        }
    }

    public class GreaterThanOrEqualZero : InputValidationError
    {
        public GreaterThanOrEqualZero(string propertyName)
        {
            base.PropertyName = propertyName;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' debe ser mayor o igual a cero.", PropertyName); }
        }
    }

    public class IncorrectType : InputValidationError
    {
        private string expectedType;

        public IncorrectType(string propertyName, string expectedType)
        {
            base.PropertyName = propertyName;
            this.expectedType = expectedType;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' debe ser del tipo {1}. Por favor revise la información introducida.", PropertyName, expectedType); }
        }
    }

    public class InvalidSymbolsError : InputValidationError
    {
        private string[] invalidSymbols;

        public InvalidSymbolsError(string propertyName, string[] invalidSymbols)
        {
            base.PropertyName = propertyName;
            this.invalidSymbols = invalidSymbols;
        }

        public override string ErrorMessage
        {
            get
            {
                return string.Format(@"Se encontraron en el Campo '{0}' los siguentes simbolos prohibidos: {1}", PropertyName, string.Join(", ", invalidSymbols));
            }
        }
    }

    public class Lenght : InputValidationError
    {
        private int maxLenght;

        public Lenght(string propertyName, int maxLenght)
        {
            base.PropertyName = propertyName;
            this.maxLenght = maxLenght;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' puede tener {1} caracteres como maximo.", PropertyName, maxLenght); }
        }
    }

    public class FixedLenght : InputValidationError
    {
        private int fixedLenght;

        public FixedLenght(string propertyName, int fixedLenght)
        {
            base.PropertyName = propertyName;
            this.fixedLenght = fixedLenght;
        }

        public override string ErrorMessage
        {
            get { return string.Format("El Campo '{0}' debe ser de {1} caracteres.", PropertyName, fixedLenght); }
        }
    }

    public class GeneralValidation : InputValidationError
    {
        private string message;

        public GeneralValidation(string message)
        {
            this.message = message;
        }

        public override string ErrorMessage
        {
            get { return message; }
        }
    }
}
